﻿using System;
using DevExpress.Xpo;
using NUnit.Framework;
using Tests.ObjectModel;

namespace Tests
{
   [TestFixture]
   public class changing_a_simple_property
   {
      #region Fields

      private bool fired;
      private Order order;

      #endregion

      #region Test Preparation

      [SetUp]
      public void SetUp()
      {
         XpoDefault.DataLayer = TestCommon.NewInMemoryDataLayer();
         order = new Order();
         fired = false;
         order.Changed += (sender, e) => { fired = true; };
         Assert.That(!fired);
      }

      #endregion

      #region Tests

      [Test]
      public void fires_the_changed_event()
      {
         order.Date = DateTime.Now;
         Assert.That(fired);
      }

      [Test]
      public void does_not_fire_the_changed_event_when_the_ignore_attribute_is_used()
      {
         order.Ignored++;
         Assert.That(!fired);
      }

      #endregion
   }
}